home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib.fmt / c / flock.man < prev    next >
Encoding:
Text File  |  1989-01-05  |  3.7 KB  |  133 lines

  1.  
  2.  
  3.  
  4. FLOCK                 C Library Procedures                  FLOCK
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      flock - apply or remove an advisory lock on an open file
  10.  
  11. SSYYNNOOPPSSIISS
  12.      ##iinncclluuddee <<ssyyss//ffiillee..hh>>
  13.  
  14.      ##ddeeffiinnee   LLOOCCKK__SSHH   11    //** sshhaarreedd lloocckk **//
  15.      ##ddeeffiinnee   LLOOCCKK__EEXX   22    //** eexxcclluussiivvee lloocckk **//
  16.      ##ddeeffiinnee   LLOOCCKK__NNBB   44    //** ddoonn''tt bblloocckk wwhheenn lloocckkiinngg **//
  17.      ##ddeeffiinnee   LLOOCCKK__UUNN   88    //** uunnlloocckk **//
  18.  
  19.      fflloocckk((ffdd,, ooppeerraattiioonn))
  20.      iinntt ffdd,, ooppeerraattiioonn;;
  21.  
  22. DDEESSCCRRIIPPTTIIOONN
  23.      _F_l_o_c_k applies or removes an _a_d_v_i_s_o_r_y lock on the file asso-
  24.      ciated with the file descriptor _f_d.  A lock is applied by
  25.      specifying an _o_p_e_r_a_t_i_o_n parameter that is the inclusive or
  26.      of LOCK_SH or LOCK_EX and, possibly, LOCK_NB.  To unlock an
  27.      existing lock _o_p_e_r_a_t_i_o_n should be LOCK_UN.
  28.  
  29.      Advisory locks allow cooperating processes to perform con-
  30.      sistent operations on files, but do not guarantee con-
  31.      sistency (i.e., processes may still access files without
  32.      using advisory locks possibly resulting in inconsistencies).
  33.  
  34.      The locking mechanism allows two types of locks: _s_h_a_r_e_d
  35.      locks and _e_x_c_l_u_s_i_v_e locks.  At any time multiple shared
  36.      locks may be applied to a file, but at no time are multiple
  37.      exclusive, or both shared and exclusive, locks allowed
  38.      simultaneously on a file.
  39.  
  40.      A shared lock may be _u_p_g_r_a_d_e_d to an exclusive lock, and vice
  41.      versa, simply by specifying the appropriate lock type; this
  42.      results in the previous lock being released and the new lock
  43.      applied (possibly after other processes have gained and
  44.      released the lock).
  45.  
  46.      Requesting a lock on an object that is already locked nor-
  47.      mally causes the caller to be blocked until the lock may be
  48.      acquired.  If LOCK_NB is included in _o_p_e_r_a_t_i_o_n, then this
  49.      will not happen; instead the call will fail and the error
  50.      EWOULDBLOCK will be returned.
  51.  
  52. NNOOTTEESS
  53.      Locks are on files, not file descriptors.  That is, file
  54.      descriptors duplicated through _d_u_p(2) or _f_o_r_k(2) do not
  55.      result in multiple instances of a lock, but rather multiple
  56.      references to a single lock.  If a process holding a lock on
  57.      a file forks and the child explicitly unlocks the file, the
  58.      parent will lose its lock.
  59.  
  60.  
  61.  
  62.  
  63. Sprite v1.0               May 22, 1986                          1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. FLOCK                 C Library Procedures                  FLOCK
  71.  
  72.  
  73.  
  74.      Processes blocked awaiting a lock may be awakened by sig-
  75.      nals.
  76.  
  77. RREETTUURRNN VVAALLUUEE
  78.      Zero is returned if the operation was successful; on an
  79.      error a -1 is returned and an error code is left in the glo-
  80.      bal location _e_r_r_n_o.
  81.  
  82. EERRRROORRSS
  83.      The _f_l_o_c_k call fails if:
  84.  
  85.      [EWOULDBLOCK]       The file is locked and the LOCK_NB
  86.                          option was specified.
  87.  
  88.      [EBADF]             The argument _f_d is an invalid descrip-
  89.                          tor.
  90.  
  91.      [EINVAL]            The argument _f_d refers to an object
  92.                          other than a file.
  93.  
  94. SSEEEE AALLSSOO
  95.      open(2), close(2), dup(2), execve(2), fork(2)
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. Sprite v1.0               May 22, 1986                          2
  130.  
  131.  
  132.  
  133.